﻿@model Vcare.ViewModels.ViewModelUserInfo

@{
    ViewBag.Title = "Create";
}

<h2>Create User</h2>
<div class="spacer"></div>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>UserInfo</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Password)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserInfo.Firstname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserInfo.Firstname)
            @Html.ValidationMessageFor(model => model.UserInfo.Firstname)
        </div>


        <div class="editor-label">
            @Html.LabelFor(model => model.UserInfo.Surname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserInfo.Surname)
            @Html.ValidationMessageFor(model => model.UserInfo.Surname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserInfo.CallCentreID)
        </div>
        <div class="editor-field">
            @if (Model.CallCentreAdministrator==true)
            {
            @Html.TextBoxFor(model => model.CallCentre.CallCentre, new { @readonly = "true" })
            @Html.HiddenFor(m => m.CallCentre.CallCentreID)
            }
            else
            {
                @Html.DropDownList("CallCentreID", (SelectList)ViewBag.CallCentreID
                    , new
                    {
                        @class = "chosen",
                        style = "width: 300px;"
                    }
                )
            }
            @Html.ValidationMessageFor(model => model.UserInfo.CallCentreID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserInfo.Notes)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.UserInfo.Notes, new { @class="largenotes" })
            @Html.ValidationMessageFor(model => model.UserInfo.Notes)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserInfo.AuthorityID, "Authority")
        </div>
        <div class="editor-field">
                @Html.DropDownList("AuthorityID", (SelectList)ViewBag.AuthorityID, 
                new 
                {
                 @class="chosen",
                 style = "width: 300px;"
                }
                )
            @Html.ValidationMessageFor(model => model.UserInfo.AuthorityID)
        </div>
        <div class="spacer"></div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
<div class="spacer"></div>
<div class="spacer"></div>

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script type="text/javascript">

    $("#CallCentreID").val("@(Model.CallCentreID)");
    $("#AuthorityID").val("@(Model.AuthorityID)");

    $(".chosen").chosen();
    
</script>